home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 06 - 1990 / 06.07 Jul 90 / Printing Primer ƒ / PrintTitle.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-11-09  |  2.6 KB  |  109 lines  |  [TEXT/KAHL]

  1. /*******************************************\
  2. *    file:         PrintTitle.c                *
  3. *    version:    0.1ß                        *
  4. *     XFCN ID        502                            *
  5. *                                            *
  6. * Print a title on the page.  By definition    *
  7. * titles are 1 line. Longer than that         *
  8. * requires a call to Printparagraph            *
  9. *                                            *
  10. * params[0] == the string                    *
  11. * params[1] == the font                        *
  12. * params[2] == the size                        *
  13. * params[3] == the style                    *
  14. * params[4] == the justification            *
  15. * -----------------------------------------    *
  16. * By:    Donald Koscheka                        *
  17. * Date:    30-OCT-89                            *
  18. * ©    Copyright 1989, Donald Koscheka            *
  19. *    All Rights Reserved                        *
  20. *                                            *
  21. * -----------------------------------------    *
  22. \*******************************************/
  23.  
  24. #include <MacTypes.h>
  25. #include <MemoryMgr.h>
  26. #include <ResourceMgr.h>
  27. #include <OSUtil.h>
  28. #include <HyperXCmd.h>
  29. #include <HyperUtils.h>
  30. #include <PrintMgr.h>
  31. #include "ReportUtils.h"
  32.  
  33.  
  34.  
  35. pascal void main( paramPtr )
  36.     XCmdBlockPtr    paramPtr;
  37. /**********************************
  38. * params[0] == the text to print.
  39. * params[1] == the font        
  40. * params[2] == the size    
  41. * params[3] == the style
  42. * params[4] == the justification
  43. **********************************/
  44. {
  45.     Handle        pH;
  46.     pInfoPtr    pp;
  47.     short        theFont;
  48.     short        theSize;
  49.     short        theStyle;
  50.     short        theJust;
  51.     long        siz;
  52.     char        *fp1;
  53.     char        *fp2;
  54.     char        fontName[256];
  55.     short        hite;
  56.     GrafPtr        oldPort;
  57.     FontInfo    fInfo;
  58.         
  59.     
  60.     if( paramPtr->paramCount && ( pH = GetSystemResource( PAGE_INFO, PAGE_ID ) ) ){
  61.         pp = (pInfoPtr)*pH;
  62.         
  63.         /*** parse the input data ***/
  64.         theFont     = 4;
  65.         theSize     = 9;
  66.         theStyle     = 0;
  67.         theJust     = teJustLeft;
  68.         
  69.         if( paramPtr->params[1] ){
  70.             paramtoPString( paramPtr, 1, (char *)fontName );
  71.             GetFNum( fontName, &theFont );
  72.         }
  73.         
  74.         if( paramPtr->params[2] )
  75.             theSize = parseNum( *(paramPtr->params[2] ) );
  76.         
  77.         if( paramPtr->params[3] )
  78.             theStyle = (short)matchToken( paramPtr->params[3], TEXT_STYLES );
  79.         
  80.         if( paramPtr->params[4] )        
  81.             theJust = (short)matchToken( paramPtr->params[4], TEXT_JUSTIFICATION );
  82.  
  83.          SetFont( (stylePtr)&(pp->curntStyle),  theFont);
  84.          SetFontSize( (stylePtr)&(pp->curntStyle),  theSize);
  85.          SetFontStyle( (stylePtr)&(pp->curntStyle),  theStyle);
  86.          SetFontJust( (stylePtr)&(pp->curntStyle),  theJust);
  87.         
  88.         /* consider drawtextrun here */
  89.         GetPort( &oldPort );
  90.         SetPort( (GrafPtr)(pp->prPort) );
  91.     
  92.         PenNormal();
  93.         SetFontStyles( pp, (stylePtr)&(pp->curntStyle) );
  94.     
  95.         GetFontInfo( &fInfo );
  96.         hite     = (fInfo.ascent + fInfo.descent + fInfo.leading);
  97.         
  98.         /*** use ( hite*4 ) to anticipate widows! ***/
  99.         CheckPageBreak( pp, hite * 4 );
  100.         PrintString( pp, paramPtr->params[0], hite );
  101.         
  102.         SetPort( oldPort );
  103.     }
  104.     
  105.     paramPtr->returnValue = NIL;
  106. }
  107.  
  108.  
  109.